package a03_哈希;

/**
 * <p>
 * a07_赎金信复习6
 * </p>
 *
 * @author flyduck
 * @since 2025/4/17
 */
public class a07_赎金信复习6 {
    public boolean canConstruct(String ransomNote, String magazine) {
        char[] chars1 = ransomNote.toCharArray();
        char[] chars2 = magazine.toCharArray();

        int[] array = new int[26];
        for (char c : chars1) {
            array[(int)c - 97]++;
        }

        for (char c : chars2) {
            array[(int)c - 97]--;
        }

        for (int i : array) {
            if(i > 0){
                return false;
            }
        }
        return true;
    }
}
